package org.springframework.fusion.service;

import java.util.Date;
import org.springframework.fusion.domain.Consumers;
import org.springframework.fusion.mapper.ConsumersMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

@Service
@Transactional(rollbackFor = Exception.class)
public class ConsumersServiceImpl extends ServiceImpl<ConsumersMapper, Consumers> implements ConsumersService {

	@Override
	@SuppressWarnings("deprecation")
	public Object saveConsumers() {
		Consumers consumers = new Consumers();
		consumers.setUsername(new Date().toLocaleString());
		this.insert(consumers);
		return consumers.getId();
	}

	@Override
	public Object page() {
		Page<Consumers> page = new Page<>(1,10);
		EntityWrapper<Consumers> eWrapper = new EntityWrapper<>();
		eWrapper.isNotNull("id");
		Page<Consumers> selectPage = this.selectPage(page, eWrapper);
		Page<Object> formatClass = selectPage.formatClass(Object.class);
		return formatClass;
	}
	
}
